package com.zf.bm.common.validator;

/**
 * 常用校验数据
 * @author zjy
 * @Date 2021/8/12 10:03
 */
public class ValidatorConst {
    private ValidatorConst() {}

    public static final String REGULAY_NUMBER = "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.";

    // 匹配所有ip，包括0.0.0.0

    public static final String IP_ALL_PATTERN_MASKLEN =  "(^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[0-9])\\."
            + REGULAY_NUMBER
            + REGULAY_NUMBER
            + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$)||(^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[0-9])\\."
            + REGULAY_NUMBER
            + REGULAY_NUMBER
            + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/([0-9]{1}|1[0-9]|2[0-9]|3[0-2])$)";

    //ip范围数组，如： 8080:8080-9090
    public static final String PORT_RANGE_PATTERN = "^(([0-9]|[1-9]\\d{1,3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])([;-]{0,1})){1,}([0-9]|[1-9]\\d{1,3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]){0,}$";
    //文件大小
    public static final String ACCOUNTTYPE = "SMTP,POP3,IMAP,,QQ"; //允许为空
    public static final String SPROTO = "Http,即时通讯,网盘,文件传输,邮件";
    public static final String PROTO = "Forum,MicroBlog,Blog,CloudNotes,SearchEngine,HTTP,QQ,RTX,Netdisk,FTP,SMB,SMTP,POP3,IMAP,Webmail";
    public static final String PROTOCOL = "6,17,0";  //UDP、TCP、无限制

    public static final String INTERGER_PATTERN = "^[\\d]{1,9}$";
    //md5长度必须是64位或者32位
    public static final String MD5 = "^$|^[0-9|A-Z|a-z]{32}$|^[0-9|A-Z|a-z]{64}$";
    //10位长度的数字
    public static final String NUMBER10 = "^[1-9][0-9]{0,9}$";
    public static final String NUMBER20 = "^[1-9][0-9]{0,19}$";

    public static final String NUMBER30 = "^[0-9a-z]{1,256}$";

    public static final String IPV6_PATTERN = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|" +
            "([0-9a-fA-F]{1,4}:){1,7}:|" +
            "([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|" +
            "([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|" +
            "([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|" +
            "([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|" +
            "([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|" +
            "[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|" +
            ":((:[0-9a-fA-F]{1,4}){1,7}|:)|" +
            "fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|" +
            "::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]|[1-9]|)[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]|[1-9]|)[0-9])|" +
            "([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]|[1-9]|)[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]|[1-9]|)[0-9]))" +
            "(?:\\/(12[0-8]|1[0-1][0-9]|[1-9]?[0-9]))?";

    //ipv4和ipv6
    public static final String IPV4_AND_IPV6_PATTERN = "(" + IP_ALL_PATTERN_MASKLEN + "|" + IPV6_PATTERN + ")";
}
